package it.irondev.appturismo.dao;

import it.irondev.appturismo.dao.example.LanguageExample;
import it.irondev.appturismo.dao.provider.LanguageSqlProvider;
import it.irondev.appturismo.entity.Language;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

public interface LanguageMapper {
    @SelectProvider(type=LanguageSqlProvider.class, method="countByExample")
    int countByExample(LanguageExample example);

    @DeleteProvider(type=LanguageSqlProvider.class, method="deleteByExample")
    int deleteByExample(LanguageExample example);

    @Delete({
        "delete from Language",
        "where idLanguage = #{idlanguage,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer idlanguage);

    @Insert({
        "insert into Language (idLanguage, name, ",
        "prefix)",
        "values (#{idlanguage,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, ",
        "#{prefix,jdbcType=VARCHAR})"
    })
    int insert(Language record);

    @InsertProvider(type=LanguageSqlProvider.class, method="insertSelective")
    int insertSelective(Language record);

    @SelectProvider(type=LanguageSqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="idLanguage", property="idlanguage", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
        @Result(column="prefix", property="prefix", jdbcType=JdbcType.VARCHAR)
    })
    List<Language> selectByExample(LanguageExample example);

    @Select({
        "select",
        "idLanguage, name, prefix",
        "from Language",
        "where idLanguage = #{idlanguage,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="idLanguage", property="idlanguage", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
        @Result(column="prefix", property="prefix", jdbcType=JdbcType.VARCHAR)
    })
    Language selectByPrimaryKey(Integer idlanguage);
    
    
    @Select({
        "select",
        "idLanguage, name, prefix",
        "from Language",
        "where prefix = #{prefix,jdbcType=VARCHAR}"
    })
    @Results({
        @Result(column="idLanguage", property="idlanguage", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
        @Result(column="prefix", property="prefix", jdbcType=JdbcType.VARCHAR)
    })
    Language selectByPrefix(String prefix);

    @UpdateProvider(type=LanguageSqlProvider.class, method="updateByExampleSelective")
    int updateByExampleSelective(@Param("record") Language record, @Param("example") LanguageExample example);

    @UpdateProvider(type=LanguageSqlProvider.class, method="updateByExample")
    int updateByExample(@Param("record") Language record, @Param("example") LanguageExample example);

    @UpdateProvider(type=LanguageSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(Language record);

    @Update({
        "update Language",
        "set name = #{name,jdbcType=VARCHAR},",
          "prefix = #{prefix,jdbcType=VARCHAR}",
        "where idLanguage = #{idlanguage,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(Language record);
}